package de.tabuma.pm.projectnavigation.view;

import de.tabuma.pm.projectnavigation.entity.ProjectNavigation;
import de.tabuma.lib.tabumaview;
import de.tabuma.pm.*;
import java.io.PrintWriter;
import java.util.*;
import java.util.logging.*;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author alefen
 */
public class remove extends tabumaview {

    private static final Logger log = Logger.getLogger(remove.class.getName());

    public remove(String servlet, Hashtable parameter) {
        super(servlet, parameter);
    }

    @Override
    public void processRequest(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {


        String element = "Do you really want to remove element {1} ?";
        String subbutton = "Remove";

        ProjectNavigation pn = (ProjectNavigation) request.getAttribute(constants.ProjectNavigation);
        element = element.replaceAll("\\{1\\}", pn.getName());

        out.println("<div class=\"navebene_remove\">");
        out.println(element);
        out.println("<form action=\""+this.getServlet()+"#"+constants.ProjectNavigationA+"\">");

        out.println("<input type=\"hidden\" name=\""+constants.ProjectNavigationRemove1+"\" value=\"true\"/>");
        out.println("<input type=\"hidden\" name=\""+constants.ProjectNavigationId+"\" value=\""+pn.getId()+"\"/>");

        Enumeration enu = this.getParameter().keys();
        while(enu.hasMoreElements()) {
            String key = (String) enu.nextElement();
            String value = (String) this.getParameter().get(key);
            out.println("<input type=\"hidden\" name=\""+key+"\" value=\""+value+"\"/>");
        }
        out.println("<input type=\"submit\" name=\"Submit\" value=\""+subbutton+"\" class=\"button\"/>");

        out.println("</form>");
        out.println("</div>");

    }

}
